package com.zhuoshi.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zhuoshi.entity.Openingreport;
import com.zhuoshi.entity.OpeningreportQueryVo;
import com.zhuoshi.entity.PayMentTypeCustom;
import com.zhuoshi.entity.RoomCustom;
import com.zhuoshi.service.OpeningreportService;

@Controller
@RequestMapping("openingreport")
public class OpeningreportController {
	@Autowired
	private OpeningreportService openingreportService;
	
//	添加开盘基本信息
	@RequestMapping("addOpeningreport")
	public ModelAndView addOpeningreport(Openingreport Openingreport,HttpSession session) throws Exception{
		Integer rows=openingreportService.addOpeningreport(Openingreport);
		Openingreport openingreport=openingreportService.selectOpeningreportById(Openingreport.getId());
		session.setAttribute("openingreport", openingreport);
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("/Admin/second/selectRooms.jsp");
		return modelAndView;
	}
	
//	查询所有开盘信息并插入开盘详细信息（房间，付款方式等）
	@RequestMapping("selectOpeningreportAll")
	public ModelAndView selectOpeningreportAll(HttpSession session) throws Exception{
		List<RoomCustom> roomCustoms=(List<RoomCustom>) session.getAttribute("roomCustoms");
		List<PayMentTypeCustom> payMentTypeCustoms=(List<PayMentTypeCustom>) session.getAttribute("payMentTypeCustoms");
		Openingreport openingreport=(Openingreport) session.getAttribute("openingreport");
//		插入开盘详细信息（房间，付款方式等）
		List<Openingreport> openingreports=openingreportService.selectOpeningreportAll(roomCustoms,payMentTypeCustoms,openingreport);
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.addObject("openingreports",openingreports);
		modelAndView.setViewName("/Admin/second/shenhe.jsp");
		return modelAndView;
	}
	
//	模糊查询开盘
	@RequestMapping("selectOpeningreportLike")
	public ModelAndView selectOpeningreportLike(String value) throws Exception{
		List<Openingreport> openingreports=openingreportService.selectOpeningreportLike(value);
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.addObject("openingreports",openingreports);
		modelAndView.setViewName("/Admin/second/shenhe.jsp");
		return modelAndView;
	}

}
